class LinkNode(object):
    
    def __init__(self,item=None,nextp=None):
        self.item=item
        self.nextp=nextp
        
    def __str__(self):
        return str(self.item)
    
    
class Link(object):
    
    #初始化
    def __init__(self):
        self.head=None
        self.tail=None
        self.length=0
        
    def __len__(self):
        return self.length
      
    #末尾添加节点
    def append(self,v:LinkNode):
        if(self.length==0):
            self.head=v
            self.tail=v
            self.length=1
        else:
            self.tail.nextp=v
            self.tail=v
            self.length=self.length+1
            
    def diedai(self):
        pointer=self.head
        while(pointer!=None):
            yield pointer
            pointer=pointer.nextp

l=Link()
n=LinkNode("han")
m=LinkNode("dong")
l.append(n)
l.append(m)

for i in l.diedai():
    print(i)
